package com.gexiaobao.pigeon.ui.auction

import android.os.Bundle
import androidx.fragment.app.Fragment
import com.gexiaobao.pigeon.app.base.BaseActivity
import com.gexiaobao.pigeon.app.util.StatusBarUtil
import com.gexiaobao.pigeon.databinding.ActivityAuctionFollowBinding
import com.gexiaobao.pigeon.ui.adapter.MyPagerAdapter
import com.gexiaobao.pigeon.ui.auction.fragment.FragmentFocusOnAuctionGoods
import com.gexiaobao.pigeon.ui.auction.fragment.FragmentFocusOnAuctionSubject
import com.gexiaobao.pigeon.viewmodel.AuctionViewModel
import me.hgj.jetpackmvvm.ext.util.setOnclickNoRepeat

/**
 * @Author      : hxw
 * @Date        : 2024/12/3 17:26
 * @Describe    : 我的参与
 */
class ActivityMyPartAuction : BaseActivity<AuctionViewModel, ActivityAuctionFollowBinding>() {

    override fun initView(savedInstanceState: Bundle?) {
        StatusBarUtil.setTranslucentForImageView(this, 0, null)
        mDatabind.includeBar.tvTitle.text = "参与"
        val mIndex = intent.getIntExtra("index", 0)
        initLayout(mIndex)
    }

    override fun onBindViewClick() {
        super.onBindViewClick()
        setOnclickNoRepeat(mDatabind.includeBar.ivBack) {
            when (it) {
                mDatabind.includeBar.ivBack -> finish()
            }
        }
    }

    private fun initLayout(mIndex: Int) {
        val tabTitle = arrayListOf("商品", "专题")
        val fragments = ArrayList<Fragment>()
        fragments.add(FragmentFocusOnAuctionGoods.newInstance(2))
        fragments.add(FragmentFocusOnAuctionSubject.newInstance(2))

        mDatabind.viewPager.adapter = MyPagerAdapter(supportFragmentManager, this, fragments, tabTitle)
        mDatabind.viewPager.offscreenPageLimit = 2
        mDatabind.tabLayout.setupWithViewPager(mDatabind.viewPager)

        mDatabind.viewPager.currentItem = mIndex
    }
}